﻿using Newtonsoft.Json;
using SBlogCore.Common.MapExtend;
using SBlogCore.Entitys.SystemManager;

namespace SBlogCore.WebAdminApplication.SysManager.Dto
{
    public class SysMenuOutPut
    {
        public long Id { get; set; }  
        /// <summary>
        /// 当设置 redirect 的时候该路由在面包屑导航中不可被点击
        /// </summary>
        public string? Redirect { get; set; }
        /// <summary>
        /// 除了 layout 对应的 path 前面需要加 /，其余子路由都不要以/开头
        /// </summary>
        public string? Path { get; set; }
        /// <summary>
        /// 路由Name不能重复
        /// </summary>
        public string? Name { get; set; }
        public string? Component { get; set; }
        public int Level { get; set; }
        public int Order { get; set; }
        public long? ParentInfoId { get; set; }
        public SysMenuMetaOut Meta { get; set; } = new SysMenuMetaOut();

        [JsonProperty("ChildrenList")]
        public List<SysMenuOutPut> Children { get; set; } = new List<SysMenuOutPut>();
    }
    public class SysMenuMetaOut
    {
        ///// <summary>
        ///// 当设置 true 的时候该路由不会再侧边栏出现 如404，login等页面(默认 false)
        ///// </summary>
        //public bool? Hidden { get; set; }
        /// <summary>
        /// 是否在左侧显示根目录
        /// </summary>
        public bool? AlwaysShow { get; set; }
        public bool? NoCache { get; set; }
        //public bool? Breadcrumb { get; set; }
        //public bool? Affix { get; set; }
        //public bool? NoTagsView { get; set; }
        //public string? ActiveMenu { get; set; }
        //public string? FollowAuth { get; set; }
        //public bool? CanTo { get; set; }
        public string? Title { get; set; }
        public string? Icon { get; set; }
    }
    public class SysManagerMaps : ISblogCoreMap
    {
        public void MapDo()
        {
            TypeAdapterConfig<SysMenu, SysMenuOutPut>.NewConfig()
                //.Map(dest => dest.Meta.Hidden, src => src.Hidden)
                .Map(dest => dest.Meta.AlwaysShow, src => src.AlwaysShow)
                .Map(dest => dest.Meta.NoCache, src => src.NoCache)
                //.Map(dest => dest.Meta.Breadcrumb, src => src.Breadcrumb)
                //.Map(dest => dest.Meta.Affix, src => src.Affix)
                //.Map(dest => dest.Meta.NoTagsView, src => src.NoTagsView)
                //.Map(dest => dest.Meta.ActiveMenu, src => src.ActiveMenu)
                //.Map(dest => dest.Meta.FollowAuth, src => src.FollowAuth)
                //.Map(dest => dest.Meta.CanTo, src => src.CanTo)
                .Map(dest => dest.Meta.Title, src => src.Title)
                .Map(dest => dest.Meta.Icon, src => src.Icon);
            TypeAdapterConfig<SysMenuInPut, SysMenu>.NewConfig()
                .Map(dest => dest.Title, src => src.Meta.Title)
                .Map(dest => dest.AlwaysShow, src => src.Meta.AlwaysShow)
                .Map(dest => dest.NoCache, src => src.Meta.NoCache)
                .Map(dest => dest.Icon, src => src.Meta.Icon);
        }
    }
}
